/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.electrode.system;

import edu.wpi.first.wpilibj.CANJaguar;
import edu.wpi.first.wpilibj.buttons.Button;
import edu.wpi.first.wpilibj.can.CANTimeoutException;
import edu.wpi.first.wpilibj.networktables.NetworkTable;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj.tables.ITable;
import org.electrode.base.LimitSwitch;
import org.electrode.base.XboxJoystick;
import org.electrode.common.RobotSystem;

/**
 * 
 * @author scheuerg
 */
public class Research extends RobotSystem {

	private XboxJoystick joystick1;
	private XboxJoystick joystick2;
	private CANJaguar can1;
	private Button button;

	public String getName() {
		return "Research";
	}

	public void init() {
		ITable table = NetworkTable.getTable(getName());
		joystick1 = new XboxJoystick(1);
		// joystick2 = new XboxJoystick(2);
		try {
			can1 = new CANJaguar(11);
		} catch (CANTimeoutException ex) {
			ex.printStackTrace();
		}
		button = new LimitSwitch(1);

	}

	public void periodicTeleop() {
		SmartDashboard.putBoolean("limit", button.get());
		if (button.get()) {
			try {
				can1.setX(0);
			} catch (CANTimeoutException ex) {
				ex.printStackTrace();
			}
			return;
		}
		joystick1.updateTable();
		// joystick2.updateTable();
		try {
			can1.setX((joystick1.getLeftX() / 1.5)
					+ (joystick1.getRightX() * 100));
		} catch (CANTimeoutException ex) {
			ex.printStackTrace();
		}

	}
}
